//
//  EFRootViewController.m
//  WZEfengAndEtong
//
//  Created by wanzhao on 16/1/28.
//  Copyright © 2016年 wanzhao. All rights reserved.
//

#import "EFRootViewController.h"
#import "EFengTabController.h"

@interface EFRootViewController ()<UINavigationControllerDelegate>

@property (nonatomic, strong) UIView *mainView;

@end

@implementation EFRootViewController


- (void)loadView
{
    self.view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    self.view.backgroundColor = WhiteColor;
    
    
       // mainView
    self.mainView = [[UIView alloc] initWithFrame:self.view.bounds];
    self.mainView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.mainView];
}

- (void)viewDidLoad
{
    
    [super viewDidLoad];
    if (IsIOS7) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }

    EFengTabController *tab = [[EFengTabController alloc] init];
    [self addChildViewController:tab];
    [self.mainView addSubview:tab.view];
    tab.view.translatesAutoresizingMaskIntoConstraints = NO;
    UIView *bb = tab.view;
    self.mainView.translatesAutoresizingMaskIntoConstraints = NO;
    UIView *aa = self.mainView;
    NSDictionary *metrics = @{@"left":@0,@"right":@0,@"spacing":@0};
    NSDictionary  *dictionary =NSDictionaryOfVariableBindings(aa,bb);
    NSString *hVFL = @"|-left-[aa]-right-|";
    NSArray *cs1 = [NSLayoutConstraint constraintsWithVisualFormat:hVFL options:NSLayoutFormatAlignAllTop|NSLayoutFormatAlignAllBottom metrics:metrics views:dictionary];
    NSString *vVFL = @"V:|-spacing-[aa]-spacing-|";
    NSArray *cs2 = [NSLayoutConstraint constraintsWithVisualFormat:vVFL options:NSLayoutFormatAlignAllRight|NSLayoutFormatAlignAllLeft metrics:metrics views:dictionary];
    NSString *hVFL1 = @"|-left-[bb]-right-|";
    NSArray *cs3 = [NSLayoutConstraint constraintsWithVisualFormat:hVFL1 options:NSLayoutFormatAlignAllTop|NSLayoutFormatAlignAllBottom metrics:metrics views:dictionary];
    NSString *vVFL1 = @"V:|-spacing-[bb]-spacing-|";
    NSArray *cs4 = [NSLayoutConstraint constraintsWithVisualFormat:vVFL1 options:NSLayoutFormatAlignAllRight|NSLayoutFormatAlignAllLeft metrics:metrics views:dictionary];
    [self.mainView addConstraints:cs3];
    [self.mainView addConstraints:cs4];
    [self.view addConstraints:cs1];
    [self.view addConstraints:cs2];}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    
    if (IsIOS7) {
        [self.navigationController.navigationBar setBarTintColor:RGBCOLOR(44, 170, 253)];
    } else {
        [self.navigationController.navigationBar setTintColor:RGBCOLOR(44, 170, 253)];
    }
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

}

@end
